<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<script src="js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/serverUrl.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<script src="js/mui.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">修改实验室公告</h1>
		</header>
		<div class="mui-content">
			<textarea id="message" rows="5" cols="20" placeholder="请输入新的实验室公告"></textarea>
			<button id="button" type="button" class="mui-btn" style="float: right; margin-right: 20px;">&nbsp;&nbsp;&nbsp;&nbsp;修改&nbsp;&nbsp;&nbsp;&nbsp;</button>
		</div>
	</body>
	<script type="text/javascript">
		mui.plusReady(function () {
			var cw = plus.webview.currentWebview();
			var labID = cw.labID;
			
			document.getElementById("button").onclick = function(){
				var requestJson = {};
				requestJson.user = JSON.parse( localStorage.getItem("userInformation") );
				requestJson.id = labID;
				requestJson.str = document.getElementById("message").value;
				$.ajax({
					//请求方式
					type: 'POST',
					dataType: 'json',
					url: serverUrl + "changeDescription",
					headers: {
						'Content-Type': 'application/json;charset=utf-8'
					},
					data: JSON.stringify(requestJson),
					//请求成功
					success: function(data) {
						if (data == "success") {
							mui.toast("修改成功！刷新实验室列表即可查看新的公告。");
							mui.back();
						} else{
							mui.toast(data);
						}
					},
					//请求失败，包含具体的错误信息
					error: function(e) {
						mui.toast("遇到了未知错误！");
					}
				});
			};
			
		});
	</script>
</html>
